/**
 * @(#)CityTourService.java, 2013-2-14. Copyright 2013 RENREN, Inc. All rights
 *                           reserved. RENREN PROPRIETARY/CONFIDENTIAL. Use is
 *                           subject to license terms.
 */
package com.wennimei.service;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Service;

import com.wennimei.util.DataUtil;
import com.wennimei.util.FileProcessor;
import com.wennimei.util.FileUtil;

/**
 * @author shichen.feng@renren-inc.com
 */
@Service
public class CityTourService {

    private static final Map<String, String> map = new HashMap<String, String>();

    @PostConstruct
    void init() {
        FileUtil.processFile(DataUtil.CITY_TOUR, new FileProcessor() {

            @Override
            public void process(String line) {
                String[] array = line.split("\\t");
                map.put(array[0], array[1]);
            }
        });
    }

    public String get(String city) {

        for (String s: map.keySet()) {
            if (city.contains(s))
                return map.get(s);

        }

        return null;
    }

    public static boolean isCityTour(String city) {
        for (String s: map.keySet()) {
            if (city.contains(s))
                return true;

        }

        return false;
    }
}
